<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" href="css/collectionEnter.css" />
	</head>

	<body>
		<form id="form">
			<div class="series-box">
				<label><i class="iconfont icon-xuliehao"></i>试剂系列码：</label>
				<input class="series-inpt" id="series-num" type="text" placeholder="请输入试剂系列码" autocomplete="off" required />
			</div>
			<div class="series-box">
				<label><i class="iconfont icon-ziyuan"></i>受试者电话：</label>
				<input class="series-inpt" id="test-tel" type="tel" placeholder="请输入受试者电话" autocomplete="off" required />
			</div>
			<h4><span>测量结果</span></h4>
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>样本号</td>
					<td>001</td>
				</tr>
				<tr>
					<td>项目名称</td>
					<td>XXX</td>
				</tr>
				<tr>
					<td>项目GOD值</td>
					<td>XXX</td>
				</tr>
				<tr>
					<td>测试结果</td>
					<td>测试结果测试结果测试结果测试结果测试结果测试结果测试结果测试结果测试结果测试结果测试结果测试结果</td>
				</tr>
				<tr>
					<td>浓度单位</td>
					<td>mmHg</td>
				</tr>
				<tr>
					<td>正常参考值</td>
					<td>80~100</td>
				</tr>
				<tr>
					<td>测试时间</td>
					<td>2018-4-10 18:18</td>
				</tr>
			</table>
			<div class="btn-box">
				<button type="">测试</button>
				<button type="button" id="send-btn">发送</button>
			</div>
		</form>
		<script type="text/javascript" src=></script>
		<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
		<script type="text/javascript">
			var showInfoArray = [];
			for(var i = 1;i < $('table tr').length+1; i++){
				showInfoArray.push($('table tr:nth-child('+i+') td:nth-child(2)').html());
			}
			//填充表单
			function fill(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9){
				$('#series-num').val(arg1);
				$('#test-tel').val(arg2);
				for(var i = 3; i < 10; i++){
					var j = i-2;
					showInfoArray[j] = 'arg'+i;
					console.log(showInfoArray[j])
				}
			}
			fill();
			//清空表单
			function resetCont(){
				$("#form")[0].reset();
				$('table tr td:nth-child(2)').text('');
			}
			//提交
			function submit(){
				$.AJAX(url, data, function(){
					//提交成功
					android.method();
				},function(){
					//提交失败
					android.method(errMsg);
				})
			}
			//测试
			function test(){
				android.method();
			}
			
			
			var toastCont = '';
			var toast = function(toastCont){
				var toastHtml = '<p class="toast-p" style="width:auto;position: fixed;opacity:1;bottom:10px;background:rgba(0,0,0,0.7);color:#fff;border-radius:6px;padding:6px;text-align:center;">'+toastCont+'</p>'
				$('body').append(toastHtml);
				var toastL = ($(window).width() - $('.toast-p').width()) / 2;
				$('.toast-p').css('left',toastL + 'px');
				setTimeout(() => $(".toast-p").css('opacity',0),1000)
			}
			$(function(){
				//点击发送按钮
				$('body').on('click','#send-btn',() => {
					var seriesNum = $('#series-num').val();
						testTel = $('#test-tel').val(),
						telReg = /^1[3|4|5|8][0-9]\d{4,8}$/;
					if(seriesNum == '' || seriesNum == null) 
						toast('请输入试剂系列码')
					else if(testTel == '' || testTel == null)
						toast('请输入受试者手机号')
					else if(!telReg.test(testTel))
						toast('请输入正确的手机号')
					else{
						console.log('正确');
						$.ajax({
							type:"POST",
							url:"http://172.16.1.76:28080/saveReagent",
							data: {
								'reagentSeriesCode': seriesNum,
								'reagentUserPhone': testTel,
								'reagentResultNum': showInfoArray[0],
								'reagentName': showInfoArray[1],
								'reagentGodNum': showInfoArray[2],
								'reagentResult': showInfoArray[3],
								'reagentMod': showInfoArray[4],
								'reagentNormal': showInfoArray[5],
								'reagentTime': showInfoArray[6]
							},
							async:true,
							success: (data) => console.log(data),
							error: () => console.log('err')
						});
						resetCont();
						toast('发送成功');
					}
				})
			})
		</script>
		
	</body>

</html>